﻿<%@ Page Title="Book Finder" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="BookFinder._Default" %>



<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
    
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script>
<script type="text/javascript">
    function loadDescription(strDesc) {
        document.getElementById('dialog').innerHTML = strDesc;
    }
    $(document).ready(function () {

        //select all the a tag with name equal to modal
        $('a[name=modal]').click(function (e) {
            //Cancel the link behavior
            e.preventDefault();

            //Get the A tag
            var id = $(this).attr('href');

            //Get the screen height and width
            var maskHeight = $(document).height();
            var maskWidth = $(window).width();

            //Set heigth and width to mask to fill up the whole screen
            $('#mask').css({ 'width': maskWidth, 'height': maskHeight });

            //transition effect		
            $('#mask').fadeIn(1000);
            $('#mask').fadeTo("slow", 0.8);

            //Get the window height and width
            var winH = $(window).height();
            var winW = $(window).width();

            //Set the popup window to center
            $(id).css('top', winH / 2 - $(id).height() / 2);
            $(id).css('left', winW / 2 - $(id).width() / 2);

            //transition effect
            $(id).fadeIn(2000);

        });

        //if close button is clicked
        $('.window .close').click(function (e) {
            //Cancel the link behavior
            e.preventDefault();

            $('#mask').hide();
            $('.window').hide();
        });

        //if mask is clicked
        $('#mask').click(function () {
            $(this).hide();
            $('.window').hide();
        });

        $(window).resize(function () {

            var box = $('#boxes .window');

            //Get the screen height and width
            var maskHeight = $(document).height();
            var maskWidth = $(window).width();

            //Set height and width to mask to fill up the whole screen
            $('#mask').css({ 'width': maskWidth, 'height': maskHeight });

            //Get the window height and width
            var winH = $(window).height();
            var winW = $(window).width();

            //Set the popup window to center
            box.css('top', winH / 2 - box.height() / 2);
            box.css('left', winW / 2 - box.width() / 2);

        });

    });

</script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    
    
  <div class="searchBar"><asp:TextBox ID="searchText" runat="server"></asp:TextBox>
        <asp:Button ID="searchButton" runat="server" onclick="searchButton_Click" 
            Text="Search" Width="135px" />  <div class="orderByBar"><span class="textBold">Order By: </span> <asp:DropDownList ID="ddl_OrderBy" runat="server" AutoPostBack="True" 
        onselectedindexchanged="ddl_OrderBy_SelectedIndexChanged">
        <asp:ListItem>Price</asp:ListItem>
        <asp:ListItem>Title</asp:ListItem>
        <asp:ListItem>Author</asp:ListItem>
        <asp:ListItem Value="ISBN"></asp:ListItem>
    </asp:DropDownList></div></div> 

         
      <asp:Repeater ID="repeater_BooksList" runat="server">
                    <HeaderTemplate>
    <div class="PageContent">                
                    </HeaderTemplate>
                    <ItemTemplate>
                    <div class="bookEntryHP">
<div class="floatbox"><img src="<%# ((BookFinder.Book) Container.DataItem).BookCoverURL == null?"/images/CoverNotAvailable.jpg":((BookFinder.Book) Container.DataItem).BookCoverURL %>" alt="<%# ((BookFinder.Book) Container.DataItem).Title %>"><%# ((BookFinder.Book)Container.DataItem).BookURL != null ? "<br /><a href=\"" + ((BookFinder.Book)Container.DataItem).BookURL + "\" ><span class=\"textBold\" style=\"text-align:center;\">Follow book to source</span></a>" : String.Empty%></div>
<p><span class="textBold"><%# ((BookFinder.Book) Container.DataItem).Title %></span>
  <%# ((BookFinder.Book)Container.DataItem).Author != null ? ("<br /><span class=\"textBold\">By</span> " + ((BookFinder.Book)Container.DataItem).Author) : String.Empty%> 
  <%# ((BookFinder.Book)Container.DataItem).PublicationDate != null ? ("<br /><span class=\"textBold\">Publication Date:</span> " + ((BookFinder.Book)Container.DataItem).PublicationDate) : String.Empty%>
  <%# ((BookFinder.Book)Container.DataItem).ISBN != "" ? ("<br /><span class=\"textBold\">ISBN:</span> " + ((BookFinder.Book)Container.DataItem).ISBN) : String.Empty%>
  <%# ((BookFinder.Book)Container.DataItem).DataSource!= null ? ("<br /><span class=\"textBold\">Found on:</span> " + ((BookFinder.Book)Container.DataItem).DataSource) : String.Empty%>
  <%# ((BookFinder.Book)Container.DataItem).CustomersReviewsURL != null ? (" (<a href=\"" + ((BookFinder.Book)Container.DataItem).CustomersReviewsURL) + "\" target=\"_blank\">Customers Reviews</a>)" : String.Empty%>
  <%# ((BookFinder.Book)Container.DataItem).Vendor != null ? ("<br /><span class=\"textBold\">Sold by:</span> " + ((BookFinder.Book)Container.DataItem).Vendor) : String.Empty%>
  <%# ((BookFinder.Book)Container.DataItem).BookFormat != null ? ("<br /><span class=\"textBold\">Book Format:</span> " + ((BookFinder.Book)Container.DataItem).BookFormat) : String.Empty%>
  <%# ((BookFinder.Book)Container.DataItem).Price != null ? ("<br /><span class=\"textBold\">Price:</span> " + ((((BookFinder.Book)Container.DataItem).Price == 0) ? "Free" : "$" + ((BookFinder.Book)Container.DataItem).Price.ToString())) : "N/A"%>
  <%# ((BookFinder.Book)Container.DataItem).Description != null ? ("<a href=\"#dialog\" name=\"modal\" onclick=\"loadDescription('<h3>" + ((BookFinder.Book) Container.DataItem).Title + "</h3>" +(((BookFinder.Book)Container.DataItem).Description).Replace("\"","").Replace("'","")+ "')\"><span class=\"textBold\">Description</span></a>").ToString() : String.Empty%>
     
  </p>

</div>
                    
                    </ItemTemplate>
                    <SeparatorTemplate>
                     <hr  width="80%"/>   
                    </SeparatorTemplate>
                    <FooterTemplate>
                        </div>
                    </FooterTemplate>
                </asp:Repeater>
            <div id="boxes"><div id="dialog" class="window"></div>
           </div>

    
<!-- Mask to cover the whole screen -->
  <div id="mask"></div>


</asp:Content>
